package LawsonTransformJava.data;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;


public class TblDate {
    protected DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
	
	public String convertDate(Date fromDate) {
			//@ TODO PLATFORM - change the date format for other platforms
			//Check for null or the default date - 1700-01-01 is specific to Oracle
			if (fromDate==null || isDefault(fromDate))
				return "";
			else
				return "\"" + df.format(fromDate) + "\"";
	}
	
	public static String convertDate(Date fromDate, String format) {
		DateFormat df2 = null; 
		if (format==null)
			format = "MM/dd/yyyy";
		df2 = new SimpleDateFormat(format);
		if (fromDate==null || fromDate.equals(""))
			return null;
		return df2.format(fromDate);
	}
	
	public DateFormat getDateFormat() {
		return df;
	}
	
	public boolean isDefault(Date fromDate) {
		if (df.format(fromDate).equals("01/01/1700"))
			return true;
		return false;
					
	}
}
